/* --------------------------------------

A4_EuropeanUFR_holdings.do

by: Kristy A.E. Jansen

This do-file: Change holdings European UFR in Jansen (2024) -- part 3
	1. Figure 6+IA8

-------------------------------------- */

/* Initialization */
clear all
set more off
capture log clear _all

global root "~/RFS_replication" // *** NEED TO CHANGE THIS TO CORRECT FILE PATH ***
global main_data $root/Data

/* Stata Packages */
*ssc install estout
*ssc install ftools
*ssc install reghdfe

/* Load Data */
use "$main_data/pseudo_data_part3_holdings.dta", clear

/* --------------------------- Figure Maturity ----------------------- */

display("Figure 6 Panel (a): Bond holdings pre/post implementation of the European-wide UFR") // same code to create Figure 6 - Panel (c)

/* Market */
preserve 
keep if inlist(holder_area, "IE", "LU", "NL") // based on Barbu 2022 and IMF reports

collapse (mean) frac_mat_bucket_areayq_* frac_mat20y_areayq,  by(UFR)

graph bar frac_mat20y_areayq frac_mat_bucket_areayq_7 , over(UFR, sort(1)) ytitle("Percentage")   ///
bar(1, color(ebblue)) bar(2, color(midgreen) ) legend(order(1 "Fraction 20-year bonds" 2 "Fraction 30-year bonds" ) pos(6) col(2)) ///
bargap(30) ylabel(0(5)20, axis(1)) blabel(bar, position(inside) format(%9.1f) color(white))

restore 

display("Figure 6 Panel (b): Bond holdings pre/post implementation of the European-wide UFR") // same code to create Figure 6 - Panel (d)

/* Historical costs */
preserve 

keep if inlist(holder_area, "AT", "BE", "FI", "FR", "DE", "GR", "IT", "PT", "SK") ///
| holder_area == "ES" // based on Barbu 2022 and IMF reports

collapse (mean) frac_mat_bucket_areayq_* frac_mat20y_areayq,  by(UFR)

graph bar frac_mat20y_areayq frac_mat_bucket_areayq_7, over(UFR, sort(1) ) ytitle("Percentage")   ///
bar(1, color(ebblue)) bar(2, color(midgreen) ) legend(order(1 "Fraction 20-year bonds" 2 "Fraction 30-year bonds" ) pos(6) col(2)) ///
bargap(30) ylabel(0(5)20, axis(1)) blabel(bar, position(inside) format(%9.1f) color(white))

restore 

/* --------------------------- Figure Risky Assets ----------------------- */

display("Figure IA8 Panel: Risky asset allocation pre/post announcement of the European-wide UFR") 

/* Market */
preserve 

keep if inlist(holder_area, "IE", "LU", "NL") // based on Barbu 2022 and IMF reports

collapse (mean) credit_rating_CB credit_rating_gov frac_gov_areayq frac_CB_areayq ,  by(UFR)
 
*Risky assets - Gov
graph bar frac_gov_areayq credit_rating_gov, over(UFR, sort(1)) ytitle("Percentage (%)/Credit Rating")   ///
bar(1, color(ebblue)) bar(2, color(midgreen) ) legend(order(1 "Allocation Gov Bonds (%)" 2 "Credit Rating" 3 ) pos(6) col(2)) ///
bargap(30) ylabel(0(5)55, axis(1)) blabel(bar, position(inside) format(%9.1f) color(white))

*Risky assets - CB
graph bar frac_CB_areayq credit_rating_CB, over(UFR, sort(1) descending) ytitle("Percentage (%)/Credit Rating")   ///
bar(1, color(ebblue)) bar(2, color(midgreen) ) legend(order(1 "Allocation Corporate Bonds (%)" 2 "Credit Rating" 3 ) pos(6) col(2)) ///
bargap(30) ylabel(0(5)60, axis(1)) blabel(bar, position(inside) format(%9.1f) color(white))

restore

/* Historical Cost */
preserve 

keep if inlist(holder_area, "AT", "BE", "FI", "FR", "DE", "GR", "IT", "PT", "SK") ///
| holder_area == "ES" // based on Barbu 2022 and IMF reports

collapse (mean) credit_rating_CB credit_rating_gov frac_gov_areayq frac_CB_areayq ,  by(UFR)
 
*Risky assets - Gov
graph bar frac_gov_areayq credit_rating_gov, over(UFR, sort(1)) ytitle("Percentage (%)/Credit Rating")   ///
bar(1, color(ebblue)) bar(2, color(midgreen) ) legend(order(1 "Allocation Gov Bonds (%)" 2 "Credit Rating" 3 ) pos(6) col(2)) ///
bargap(30) ylabel(0(5)55, axis(1)) blabel(bar, position(inside) format(%9.1f) color(white))

*Risky assets - CB
graph bar frac_CB_areayq credit_rating_CB, over(UFR, sort(1) descending) ytitle("Percentage (%)/Credit Rating")   ///
bar(1, color(ebblue)) bar(2, color(midgreen) ) legend(order(1 "Allocation Corporate Bonds (%)" 2 "Credit Rating" 3 ) pos(6) col(2)) ///
bargap(30) ylabel(0(5)60, axis(1)) blabel(bar, position(inside) format(%9.1f) color(white))

restore


